package com.world.rickcloudendpoint.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * @description: 基本异常类
 * @author: jlsong
 * @date: 2022/01/15 11:51:41
 * @version: 1.0
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class BaseException extends Exception implements Serializable {

    private static final long serialVersionUID = 1627617496850836357L;

    private Integer errorCode;
    private String errorMsg;

    public BaseException(ErrorInfo errorInfo) {
        super(errorInfo.getMessage());
        this.errorCode = errorInfo.getCode();
        this.errorMsg = errorInfo.getMessage();
    }

    public BaseException(int errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BaseException(String errorMsg) {
        super(errorMsg);
        this.errorCode = 500;
        this.errorMsg = errorMsg;
    }
}
